#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
string s;
int mp[26];
int main()
{
    cin >> s;
    int kind = 0;
    int n = s.size();
    int ret = n;
    for (int left = 0, right = 0; right < n; right++)
    {
        if (mp[s[right] - 'a']++ == 0)
        {
            kind++;
        }
        while (kind == 26)
        {
            if (ret > right - left + 1)
            {
                ret = right - left + 1;
            }
            if (mp[s[left] - 'a']-- == 1)
            {
                kind--;
            }
            left++;
        }
    }
    cout << ret;
    return 0;
}